package com.dnjn.happiness.system.api.factory;

import com.dnjn.happiness.common.core.domain.R;
import com.dnjn.happiness.system.api.RemoteDeptService;
import com.dnjn.happiness.system.api.domain.SysDept;
import com.dnjn.happiness.system.api.model.TeamTreeSelectVO;
import com.dnjn.happiness.system.api.model.TreeSelectVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RemoteDeptFallbackFactory implements FallbackFactory<RemoteDeptService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteDeptFallbackFactory.class);
    @Override
    public RemoteDeptService create(Throwable throwable) {
        log.error("调用部门微服务失败：" + throwable.getMessage());
        return new RemoteDeptService() {
            @Override
            public R<SysDept> getInfoById(Long deptId, String source) {
                return R.fail("查询部门信息失败：{}" + throwable.getMessage());
            }

            @Override
            public R<List<SysDept>> selectDeptList(SysDept dept,String source) {
                return R.fail("查询部门列表失败：{}" + throwable.getMessage());
            }

            @Override
            public R<List<Long>> getListAll(String source) {
                return R.fail("查询部门列表失败：{}" + throwable.getMessage());
            }

            @Override
            public R<List<SysDept>> getDeptListByDeptId(Long deptId, String source) {
                return R.fail("查询部门列表失败：{}" + throwable.getMessage());
            }

            @Override
            public R<List<TreeSelectVO>> getDeptTreeApi(SysDept dept, String source) {
                return R.fail("查询子部门列表失败：{}" + throwable.getMessage());
            }

            @Override
            public R<List<SysDept>> getChildDeptListById(Long deptId, String source) {
                return R.fail("查询子部门列表失败：{}" + throwable.getMessage());
            }

            @Override
            public R<SysDept> selectDeptByChildUserId(Long deptId, String source) {
                return R.fail("查询部门失败：{}" + throwable.getMessage());
            }

            @Override
            public R<SysDept> selectSuperDeptList(Long userId, String source) {
                return R.fail("查询部门失败：{}" + throwable.getMessage());
            }

            @Override
            public R<List<TeamTreeSelectVO>> selectTeamTreeList(SysDept dept, String source) {
                return R.fail("查询部门失败：{}" + throwable.getMessage());
            }

            @Override
            public R<List<TeamTreeSelectVO>> getTeamTreeByDeptId(Long deptId, String source) {
                return R.fail("查询部门失败：{}" + throwable.getMessage());
            }
        };
    }
}
